//
// Created by Lenovo on 2020/10/14.
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
#define ll long long
const int maxn = 1e4+10;
int oula[maxn];
int f[maxn];
int euler(int n)
{
    int i,j,res=n,temp=n;
    for(i=2;i*i<=temp;i++)
    {
        if(temp%i==0)
        {
            res=res/i*(i-1);//先进行除法是为了防止中间数据爆范围
            while(temp%i==0)
                temp/=i;
        }
    }
    if(temp>1)
        res=res/temp*(temp-1);
    return res;
}
void initF()
{
    f[1] = 2;
    for(int i = 2;i<maxn;i++) f[i] = f[i-1]+euler(i);
}
int main()
{
    initF();
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        cout<<f[n]<<endl;
    }
}